package co.th.bjc.md.dbonline.control;

import org.apache.log4j.Logger;

import co.th.bjc.md.dbonline.bean.LoginDBOnlineBean;
import co.th.bjc.md.helper.LoginHelper;
import co.th.bjc.md.model.Login;

public class LoginDBOnlineControl {
	private Logger _logger = Logger.getLogger(getClass().getName());

	public LoginDBOnlineBean verifyLoginDBOnline(LoginDBOnlineBean bean) throws Exception{
		try {
			Login login = new Login(bean.getUsername(), bean.getPassword());
			login = LoginHelper.verifyLogin(bean.getUsername(), bean.getPassword());
			if (login == null){
				throw new Exception("Login Fail.");
			}
			
			bean.setActive(login.getActive());
		} catch (Exception ex) {
			_logger.error(ex.getMessage());
			throw ex;
		}
		return bean;
	}
}
